package com.linhh.mall.center.server.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.linhh.mall.center.api.MemberInfoService;
import com.linhh.mall.center.common.pojo.BrandInfo;
import com.linhh.mall.center.common.pojo.MemberInfo;
import com.linhh.mall.center.server.mappers.MemberInfoMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * 查询接口实现类
 * @Author linhh
 * @Date 2022 12 13 23 24
 **/
@Service
public class MemberInfoServiceImpl implements MemberInfoService {

    @Autowired
    private MemberInfoMapper memberInfoMapper;

    @Override
    public PageInfo<MemberInfo> getMember(Integer page, Integer size) {
        PageHelper.startPage(page,size);
        Example example = new Example(MemberInfo.class);
        example.setOrderByClause("id desc");
        List<MemberInfo> allBrandList = memberInfoMapper.selectByExample(example);
        PageInfo<MemberInfo> pageInfo = new PageInfo<>(allBrandList);
        return pageInfo;
    }


    @Override
    public int deleteMemberInfo(Long id) {
        memberInfoMapper.deleteByPrimaryKey(id);
        return 1;
    }

    @Override
    public int updateMemberInfo(MemberInfo memberInfo) {
        memberInfoMapper.updateByPrimaryKeySelective(memberInfo);
        return 1;
    }

    @Override
    public int addMemberInfo(MemberInfo memberInfo) {
        memberInfoMapper.insertSelective(memberInfo);
        return 1;
    }

    @Override
    public List<MemberInfo> getAllMemberInfo() {
        List<MemberInfo> memberInfos = memberInfoMapper.selectAll();
        return memberInfos;
    }
}
